package com.cloudxingkong.dianyinke.Student.Ui;

import android.content.Intent;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import com.cloudxingkong.dianyinke.R;
import com.cloudxingkong.dianyinke.VideoPlay.SuperVideoPlay;
import com.cloudxingkong.dianyinke.VideoPlay.VideoPlay;
import com.nostra13.universalimageloader.core.ImageLoader;

import de.hdodenhof.circleimageview.CircleImageView;


/**
 * 视频播放：详情页
 */
public class VideoTeachingDetail extends AppCompatActivity  {
    private TextView videoDetail_teacherName,videoDetail_title,videoDetail_playNum,videoDetail_commend,videoDetail_content;
    private String memname,title,views,likes,note,vID,vPath,time;
    private CircleImageView circleImageView;
    private SharedPreferences sharedPreferences;
    private String pic,pic2;
    private ImageView videoDetail_imageView;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_video_teaching_detail);
        init();

    }

    private void init() {
        videoDetail_teacherName  = (TextView) findViewById(R.id.videoDetail_teacherName);
        videoDetail_title  = (TextView) findViewById(R.id.videoDetail_title);
        videoDetail_playNum  = (TextView) findViewById(R.id.videoDetail_playNum);
        videoDetail_commend  = (TextView) findViewById(R.id.videoDetail_commend);
        videoDetail_content  = (TextView) findViewById(R.id.videoDetail_content);
        videoDetail_imageView = ((ImageView) findViewById(R.id.vt_cover));
        circleImageView = (CircleImageView) findViewById(R.id.videoDetail_pic);

        Intent intent = getIntent();
        title=intent.getStringExtra("vTitle");
        memname=intent.getStringExtra("vMemname");
        views=intent.getStringExtra("vViews");
        likes=intent.getStringExtra("vLikes");
        time =intent.getStringExtra("vTime");
        note=intent.getStringExtra("vNote");
        vID = intent.getStringExtra("vID");
        vPath = intent.getStringExtra("vPath");

        pic = intent.getStringExtra("pic");
        pic2 = intent.getStringExtra("pic2");
        if (pic!=null){
            ImageLoader.getInstance().displayImage(pic, circleImageView);
        }
       if (pic2!=null){
           ImageLoader.getInstance().displayImage(pic2, videoDetail_imageView);
       }
        videoDetail_teacherName.setText(memname);
        videoDetail_playNum.setText(views);
        videoDetail_commend.setText(likes);
        videoDetail_content.setText(note);
        videoDetail_title.setText(title);


        sharedPreferences = getSharedPreferences("data_dyk", 0);
        SharedPreferences.Editor edit = sharedPreferences.edit();
        edit.putString("vTitle",title);
        edit.putString("vNote", note);
        edit.putString("vTime",time);
        edit.putString("vID",vID);
        edit.commit();
    }

    public void play(View view) {
        Intent intent = new Intent(this, SuperVideoPlay.class);
        intent.putExtra("videoPath",vPath);
        startActivity(intent);
    }
    public void back(View view) {
        finish();
    }

}
